﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PhotoGalleryEnteties;

namespace PhotogalleryModel
{
    public class NewsRepository
    {
        private IContext _context;

        public NewsRepository (ModelContext context)
        {
            _context = context.Context;
        }

        public IEnumerable< PhotoRecentCommented> GetRecentNews(GalleryUser user)
        {
            foreach (PhotoInfo photo in _context.RecentCommented( user.UserId ))
            {
                yield return new PhotoRecentCommented(photo);
            }
        }

        public int NewsCount(GalleryUser user)
        {
            return _context.RecentCommented(user.UserId).Count();
        }

    }
}
